/**
 * This file is a part of qloudgen-sec. 
 * You can redistribute qloudgen-sec and/or modify it under the terms of the Lesser GNU General Public License version 3. 
 * qloudgen-sec is distributed WITHOUT ANY WARRANTY. 
 *
 * See the Lesser GNU General Public License for more details at http://www.gnu.org/licenses/. 
 **/
package org.qloudgen.sec.osgi.shiro.authc.impl;

import java.util.Map;

import org.qloudgen.sec.shiro.SecurityUtil;
import org.qloudgen.sec.osgi.shiro.authc.AuthenticationService;

/**
 * <p>Title: Authentication Service implementation for OSGi</p>
 * <p>Description: Implements authentication service for osgi container.</p>
 * <p>Copyright: qloudgen/sec 2014</p>
 * @author <a href="mailto:hyq.dd.sun@gmail.com">glue.3M</a>
 */
public class AuthenticationServiceImpl implements AuthenticationService {
	/**
	 * Login.
	 *
	 * @param ticket
	 */
	public void login(final String ticket) {
		SecurityUtil.getInstance().login( ticket );
	}
	
	/**
	 * Logout.
	 *
	 * @param ticket
	 */
	public void logout(final String ticket) {
		SecurityUtil.getInstance().logout( ticket );
	}
	
	/**
	 * Test
	 *
	 * @param ticket
	 * @return boolean
	 */
	public boolean isAuthenticated(final String ticket) {
		return SecurityUtil.getInstance().isAuthenticated( ticket );
	}
	
	/**
	 * Returns current user id after authentication..
	 *
	 * @param ticket
	 * @return String
	 */
	public String getUserId(final String ticket) {
		return SecurityUtil.getInstance().getUserId( ticket );
	}
	
	/**
	 * Returns current user attributes after authentication.
	 *
	 * @param ticket
	 * @return Map<String,Object>
	 */
	public Map<String,Object> getUserAttributes(final String ticket) {
		return SecurityUtil.getInstance().getUserAttributes( ticket );
	}
}